package com.gw.udf;

import org.apache.hadoop.hive.ql.exec.UDF;

import com.gw.util.Constants;
import com.gw.util.Location;

/**
 * 根据经纬度获取省份
 * @author King
 * @main 346238763@qq.com
 * @date 2018年3月20日
 */
public class LL2Province extends UDF{
	
	
	private static Location l = null;

	@SuppressWarnings("finally")
	public static String evaluate(String Longitude , String Latitude){
		
		   String result = new String();
		   try{  
			   if(l == null){
				   l = new Location(Constants.geollFile_CN);
			   }
			   result = l.getCNProvince(Longitude, Latitude).trim();
			}catch(Exception e){
			   result = null;
	           throw e;
	        }finally{
	        	return result;
	        }
		     
   }
	
	public static void main(String[] args)  {
		String str = evaluate("119.3", "26.08");
      	System.out.println(str);

	}
 }
